﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using BLL;
using IBLL;

namespace Web
{
    public partial class AdminLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void MsgBox(string strMsg, string URL)
        {
            string StrScript;
            StrScript = ("<script language=javascript>");
            StrScript += ("alert('" + strMsg + "');");
            StrScript += ("window.location='" + URL + "';");
            StrScript += ("</script>");
            System.Web.HttpContext.Current.Response.Write(StrScript);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            BLL.AdminBLL adminBll = (BLL.AdminBLL)BLLFAC.DataAccess.CreateAdmin();
            string ip =System.Web.HttpContext.Current.Request.UserHostAddress;
            if (null != adminBll)
            {
                if (adminBll.Login(TextBox1.Text, TextBox2.Text, ip))
                {
                    Session["adminName"] = TextBox1.Text; 
                    Response.Redirect("adminmain.aspx");
                    
                }
            }else
            {
                Response.Redirect("AdminLogin.aspx");
            }

        }

    }
}